/*
 * Copyright 2008, Freescale Semiconductor, Inc
 * Andy Fleming
 *
 * Based vaguely on the Linux code
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */
#ifndef __MMC_COMMAND
#define __MMC_COMMAND
//static int cur_dev_num = -1;
/* frequency bases */
/* divided by 10 to be nice to platforms without floating point */
#ifdef CONFIG_SD_DEBUG
#define DEBUG_SD(s) {\
		char str[64] ;\
		sprintf(str,"SD_DEBUG:%s\n",s);\
		printf("%s",str);\
	}
#else
#define  DEBUG_SD(s) 
#endif

#ifdef CONFIG_MMC_DEBUG
#define DEBUG_MMC(s) {\
		char str[64] ;\
		sprintf(str,"MMC_DEBUG:%s\n",s);\
		printf("%s",str);\
	}
#else
#define  DEBUG_MMC(s) 
#endif
int mmc_init_devdesc(struct mmc *mmc);
int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data);
int mmc_send_app_op_cond(struct mmc* mmc, u32 *rocr);
int sd_send_op_cond(struct mmc *mmc);
int mmc_send_cid(struct mmc * mmc);
int mmc_into_trans_mode(struct mmc * mmc);
int block_send_csd(struct mmc * mmc);
int mmc_relative_addr(struct mmc *mmc);
int mmc_send_op_cond(struct mmc *mmc);
int mmc_set_blocklen(struct mmc *mmc, int len);
ulong mmc_write(struct mmc *mmc, ulong start, lbaint_t blkcnt, const void*src);
int mmc_read_multi(struct mmc *mmc,void *dst,uint secnum,uint blkcnt);
int mmc_read_block(struct mmc *mmc, void *dst, uint blocknum);
//int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size);
//ulong mmc_bread(int dev_num, ulong start, lbaint_t blkcnt, void *dst);
int mmc_select_card(struct mmc* mmc);
int mmc_go_idle(struct mmc* mmc);
int mmc_send_ext_csd(struct mmc *mmc, char *ext_csd);
void mmc_set_ios(struct mmc *mmc);
void mmc_set_clock(struct mmc *mmc, uint clock);
void mmc_set_bus_width(struct mmc *mmc, uint width);
int mmc_send_if_cond(struct mmc *mmc);
int mmc_app_set_bus_width(struct mmc *mmc, int width);
int mmc_get_sector_count(struct mmc *mmc);
int mmc_startup(struct mmc *mmc);
int sd_startup(struct mmc *mmc);
int mmc_calculate_dtr(int m,int e);
#else
extern int mmc_init_devdesc(struct mmc *mmc);
extern int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data);
extern int mmc_send_app_op_cond(struct mmc* mmc, u32 *rocr);
extern int sd_send_op_cond(struct mmc *mmc);
extern int mmc_send_cid(struct mmc * mmc);
extern int mmc_into_trans_mode(struct mmc * mmc);
extern int block_send_csd(struct mmc * mmc);
extern int mmc_relative_addr(struct mmc *mmc);
extern int mmc_send_op_cond(struct mmc *mmc);
extern int mmc_set_blocklen(struct mmc *mmc, int len);
extern ulong mmc_write((struct mmc *mmc, ulong start, lbaint_t blkcnt, const void*src);
extern int mmc_read_multi(struct mmc *mmc,void *dst,uint secnum,uint blkcnt);
extern int mmc_read_block(struct mmc *mmc, void *dst, uint blocknum);
//extern int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size);
//extern ulong mmc_bread(int dev_num, ulong start, lbaint_t blkcnt, void *dst);
extern int mmc_select_card(struct mmc* mmc);
extern int mmc_go_idle(struct mmc* mmc);
extern int mmc_send_ext_csd(struct mmc *mmc, char *ext_csd);
extern void mmc_set_ios(struct mmc *mmc);
extern void mmc_set_clock(struct mmc *mmc, uint clock);
extern void mmc_set_bus_width(struct mmc *mmc, uint width);
extern int mmc_send_if_cond(struct mmc *mmc);
extern int mmc_app_set_bus_width(struct mmc *mmc, int width);
extern int mmc_get_sector_count(struct mmc *mmc);

extern int mmc_startup(struct mmc *mmc);
extern int sd_startup(struct mmc *mmc);
extern int mmc_calculate_dtr(int m,int e);
#endif
